import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';
import 'package:xin_nuo_pda/routes/Routes.dart';
import 'package:xin_nuo_pda/values/constant.dart';
import 'package:xin_nuo_pda/views/SubTitleBar.dart';
import 'package:xin_nuo_pda/views/TextView.dart';
import 'package:xin_nuo_pda/views/edittext/TitleEditText.dart';

import 'EndWorkController.dart';

class EndWorkPage extends StatelessWidget {
  final logic = Get.put(EndWorkController());
  String editText = "";
  FocusNode focusNode1 = FocusNode();
  FocusNode focusNode2 = FocusNode();
  TextEditingController textEditingController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(USER),
        ),
        body: SingleChildScrollView(
          child: Container(
              child: Column(
                children: [
                  SubTitleBar("出站", '下一步', () {
                    if(logic.lotEntity == null){
                      Get.snackbar('提示', "请先扫描批次号",
                          colorText: Colors.white, backgroundColor: Colors.black87);
                      return;
                    }

                    logic.next();
                  }),
                  TitleEditText(
                    "批次ID:",
                    "请扫描批次ID",
                    (value) {
                      logic.getLotInfo(value);
                      // focusNode1.unfocus();
                      // FocusScope.of(Get.context!).requestFocus(focusNode2);
                    },
                    focusNode: focusNode1,
                  ),
                  // TitleEditText(
                  //   "设备ID:",
                  //   "请扫描设备ID",
                  //   (value) {
                  //     logic.eqpID = value;
                  //   },
                  //   focusNode: focusNode2,
                  // ),
                  GetBuilder<EndWorkController>(
                      builder: (logic) => Column(
                            children: [
                              TextView("设备ID:", logic.lotEntity?.eQUIPMENTID ?? ''),
                              TextView("批次数量:", logic.lotEntity?.mAINQTY.toString() ?? '0'),
                              TextView("批次状态:", logic.lotEntity?.sTATE.toString() ?? ''),
                              TextView("当前工步:", (logic.lotEntity?.sTEPNAME.toString() ?? '') + '/' + (logic.lotEntity?.sTEPDESC.toString() ?? '')),
                            ],
                          ),
                       id: logic.lotEntityID,
                  ),
                ],
              ),
            ),
        ));
  }
}
